import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import MyView from '../views/myTest'
import Login from '../views/login/login'
import en from '../i18n/lang/en'
import HomeMain from '@/views/index/mainIndex'
import Layout from '@/views/layout/layout'
const Icon = () => import('@/views/icon/index')
const NavClassify = () => import('@/views/syssetting/navClassify')
const UserSetting = () => import('@/views/syssetting/UserSetting')
const TestHome  = () => import('@/views/TestManage/index')
const NotFound = () => import('@/views/page404')
const Forbidden = () => import('@/views/page403')
const TestReport  = () => import('@/views/TestManage/Report')
const CheckChannel  = () => import('@/views/TestManage/CheckChannel')
const Test  = () => import('@/views/TestPage/index')
const htmlpanels  = () => import('@/views/TestPage/HtmlPanel')
const SvgView = () => import('@/views/Tools/svg')
const OtfView = () => import('@/views/Tools/otf')
const outpage = () => import('@/views/Tools/out')
const ShortView = () => import('@/views/Tools/short')
const FilePush = () => import('@/views/Tools/filePush')
const applist = () => import('@/views/AppManage/apphome')
const appupload = () => import('@/views/AppManage/appupload')
const appdetail = () => import('@/views/AppManage/AppDetail')
const toIni = () => import('@/views/Tools/Ini')
const StrTojson = () => import('@/views/Tools/StrTojson')
const TimeTansfer = () => import('@/views/Tools/TimeIndex')
const OcrView = () => import('@/views/Tools/Ocr')
const WoffView = () => import('@/views/Tools/Woff')
const Weditor = () => import('@/views/Tools/weditor')
const Qrcodes = () => import('@/views/Tools/Qr')
const CloudFont = () => import('@/views/ColorFont/cfont')
const pagePermissions = () => import('@/views/permissions/pagePermissions')
const btnPermissions = () => import('@/views/permissions/btnPermissions')
const Project  = () => import('@/views/project/index')
const ApiList  = () => import('@/views/project/detail')
const ApiInfo  = () => import('@/views/project/apidetail')


Vue.use(Router)

let routeNmae = en.routeNmae;

let defaultRouter = [ 
    {
        path: '/',
        redirect: '/index',
        hidden: true,
        children: []
    },
    {
        path: '/login',
        name: routeNmae.Login,
        component: Login,
    },
    {
        path: '/',
        iconCls: 'fa fa-home', // 图标样式class
        name: routeNmae.home,
        component: Layout,
        alone: true,
        hidden: true,
        children: [
            {
                path: '/index',
                iconCls: 'fa fa-dashboard', // 图标样式class
                name: routeNmae.home,
                component: HomeMain,
                children: []
            }
        ]
    },
    {
        path: '/403',
        component: Layout,
        hidden: true,
        name: routeNmae.Forbidden,
        children: [
            {
                path: '/403',
                iconCls: 'fa fa-dashboard', // 图标样式class
                name: routeNmae.Forbidden,
                component: Forbidden,
                children: []
            }
        ]       
    },
    {
        path: '*',
        redirect: '/404',
        component: Layout,
        hidden: true,
        // alone: true,
        children: [
            {
                path: '/404',
                iconCls: 'fa fa-dashboard', // 图标样式class
                name: routeNmae.NotFound,
                component: NotFound,
                children: []
            }
        ]
    },
    // {
    //     path: '*',
    //     name: "404",
    //     component: NotFound
    // },
]


let addRouter = [
    {
        path: '/',
        iconCls: 'fa fa-pencil fa-fw', // app托管
        name: routeNmae.projectManage,
        component: Layout,
        // hidden: true,
        children: [
            {
                path: '/Product',
                iconCls: 'fa fa-list fa-fw', // 图标样式class
                name: routeNmae.projectList,
                component: Project,
                children: []
            },{
                path: '/Product/ApiList',
                iconCls: 'fa fa-bars', // 图标样式class
                name: routeNmae.ApiList,
                component: ApiList,
                children: []
            },{
                path: '/Product/ApiInfo',
                iconCls: 'el-icon-refrigerator', // 图标样式class
                name: routeNmae.ApiInfo,
                component: ApiInfo,        
                children: []
            }
        ],
        meta: {
            title: '项目管理',
            roles: ['superAdmin']
        },
    },
    {
        path: '/test',
        iconCls: 'fa fa-telegram',
        name: routeNmae.TestManage,
        component: Layout,
        children: [
            {
                path: '/test/Testhome',
                iconCls: 'fa fa-briefcase', // 图标样式class
                name: routeNmae.TestHome,
                component: TestHome,
                children: []
            },{
                path: '/test/TestReport',
                iconCls: 'fa fa-bar-chart', // 图标样式class
                name: routeNmae.TestReport,
                component: TestReport,
                children: []
            },{
                path: '/test/CheckChannel',
                iconCls: 'fa fa-eye', // 图标样式class
                name: routeNmae.CheckChannel,
                component: CheckChannel,
                children: []
            }
        ],
        meta: {
            title: '测试管理',
            roles: ['superAdmin','TEST']
        },
    },
    {
        path: '/app',
        iconCls: 'fa fa-cloud-upload', // app托管
        name: routeNmae.appmanage,
        component: Layout,
        children: [
            {
                path: '/app/appupload',
                iconCls: 'el-icon-upload2', // 图标样式class
                name: routeNmae.appupload,
                component: appupload,
                children: []
            },
            {
                path: '/app/applist',
                iconCls: 'el-icon-upload2', // 图标样式class
                name: routeNmae.applist,
                component: applist,
                children: []
            }
        ],
        meta: {
            title: '应用托管',
            roles: ['superAdmin',"AppAdmin"]
        },
    },
    {
        path:"/tools",
        iconCls: 'el-icon-s-cooperation',
        name: routeNmae.Tools,
        component: Layout,
        children: [
            {
                path:"/tools/getini",
                iconCls: 'fa fa-file-code-o',
                name: routeNmae.toIni,
                component: toIni,
                children: []
            },
            {
                path:"/tools/short",
                iconCls: 'fa fa-file-code-o',
                name: routeNmae.ShortView,
                component: ShortView,
                children: []
            },
            {
                path:"/tools/svg",
                iconCls: 'fa fa-file-code-o',
                name: routeNmae.SvgView,
                component: SvgView,
                children: []
            },
            {
                path:"/tools/otf",
                iconCls: 'fa fa-file-code-o',
                name: routeNmae.OtfView,
                component: OtfView,
                children: []
            },
            {
                path:"/tools/StrToJson",
                iconCls: 'fa fa-file-code-o',
                name: routeNmae.StrTojson,
                component: StrTojson,
                children: []
            },
            // {
            //     path:"/excel",
            //     iconCls: 'fa fa-align-center',
            //     name: routeNmae.els,
            //     component: Exs,
            //     children: []
            // },
            {
                path:"/tools/CloudFont",
                iconCls: 'fa fa-etsy',
                name: routeNmae.cloudFont,
                component: CloudFont,
                children: []
            },{
                path:"/tools/getQr",
                iconCls: 'fa fa-qrcode',
                name: routeNmae.getQrcode,
                component: Qrcodes,
                children: []
            },{
                path: '/tools/timetansfer',
                iconCls: 'fa fa-arrows-h',
                component: TimeTansfer,
                name: routeNmae.TimeTansfer,
                children: []
            },{
                path: '/tools/ocr',
                iconCls: 'fa fa-search',
                component: OcrView,
                name: routeNmae.OcrView,
                children: []
            },{
                path: '/tools/woff',
                iconCls: 'fa fa-facebook-f',
                component: WoffView,
                name: routeNmae.WoffView,
                children: []
            },
            {
                path: '/tools/weditor',
                iconCls: 'fa fa-pencil fa-fw',
                component: Weditor,
                // hidden: true,
                name: routeNmae.Weditor,
                children: []
            },
            {
                path: '/tools/outpage',
                iconCls: 'fa fa-asl-interpreting',
                component: outpage,
                // hidden: true,
                name: routeNmae.JumpPage,
                children: []
            }
        ],
        meta: {
            title: '工具',
            roles: ['superAdmin',"Tools"]
        },
    },
    {
        path: '/icon',
        iconCls: 'fa fa-paw', // 图标样式class
        name: routeNmae.icon,
        component: Layout,
        // hidden: true,
        children: [
            {
                path: '/icon',
                iconCls: 'fa fa-life-ring', // 图标样式class
                name: routeNmae.builtInIcon,
                component: Icon,
                children: []
            }
        ]
    },
    {
        path: '/permissin',
        iconCls: 'fa fa-user-secret',
        name: routeNmae.permissions,
        component: Layout,
        children: [
            {
            path: '/permissin/pagePermissions',
            iconCls: 'fa fa-expeditedssl', // 图标样式class
            name: routeNmae.pageControl,
            component: pagePermissions,
            children: []
          },
          {
            path: '/permissin/btnPermissions',
            iconCls: 'fa fa-toggle-on', // 图标样式class
            name: routeNmae.btnControl,
            component: btnPermissions,
            children: []
          }
        ],
        meta: {
            title: '用户权限',
            roles: ['superAdmin'] // 普通的用户角色
        },
    },{   
        path: '/setting',
        iconCls: 'el-icon-setting', // 图标样式class
        name: routeNmae.systemSettings,
        component: Layout,
        children: [
            {
                path: '/setting/navClassifies',
                iconCls: 'el-icon-menu', // 图标样式class
                name: routeNmae.navMenu,
                component: NavClassify,
                children: []
            },{
                path:"/setting/userSetting",
                iconCls:'fa fa-user-o fa-fw',
                name: routeNmae.UserSetting,
                component: UserSetting,
                children: []
            } 
        ],
        meta: {
            title: '系统设置',
            roles: ['superAdmin'] // 普通的用户角色
        },
    }
]

 

export default new Router({
    // mode: 'history',
    // base: '/view/',
    routes: defaultRouter
})
export {defaultRouter, addRouter}
